/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.DataTraveler.com.dao.imp;

import com.DataTraveler.app.bean.Articulo;
import com.DataTraveler.app.dao.ArticulosDao;
import com.DataTraveler.com.dal.Conexion;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author curso
 */
public class ArticuloDaoImp implements ArticulosDao {

    public List<Articulo> getAll() {
        Articulo articulo = null;
        List<Articulo> listArticulos = new ArrayList<Articulo>();
        try {
            String sql = " SELECT * FROM app.articulos ";
            Conexion c = Conexion.getConexion();
            ResultSet rs = c.getResultSet(sql);


            while(rs.next()){
                articulo = new Articulo();
                articulo.setCodigoArticulo(rs.getInt("codigoarticulo"));
                articulo.setCantidadStock(rs.getInt("cantidadstock"));
                articulo.setDescripcion(rs.getString("descripcion"));
                articulo.setPrecio(rs.getDouble("precio"));
                listArticulos.add(articulo);

            }
        } catch (SQLException ex) {
            Logger.getLogger(ArticuloDaoImp.class.getName()).log(Level.SEVERE, null, ex);
        }

        return listArticulos;
    }

}
